/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package telas;

import Util.util;
import javax.swing.JOptionPane;
import login.Login;
import login.LoginDAO;
import profissional.Profissional;
import profissional.profissionalDAO;


public class CadProfissional extends javax.swing.JDialog {

    
    
     
    public CadProfissional() {
        setLocationRelativeTo(null); 
        initComponents();
        setModal(true);
        
          
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        nivelprofissional = new javax.swing.JComboBox();
        confirmarprofissional = new javax.swing.JPasswordField();
        senhaprofissional = new javax.swing.JPasswordField();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        loginprofissional = new javax.swing.JTextField();
        nome1 = new javax.swing.JLabel();
        edtNomeprofissional = new javax.swing.JTextField();
        RG1 = new javax.swing.JLabel();
        edtRGprofissional = new javax.swing.JFormattedTextField();
        CPF1 = new javax.swing.JLabel();
        edtCPFprofissional = new javax.swing.JFormattedTextField();
        enderço1 = new javax.swing.JLabel();
        edtEnderecoprofissional = new javax.swing.JTextField();
        N1 = new javax.swing.JLabel();
        edtNumprofissional = new javax.swing.JTextField();
        bairro1 = new javax.swing.JLabel();
        edtBairroprofissional = new javax.swing.JTextField();
        telefone1 = new javax.swing.JLabel();
        edtTelefoneprofissional = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        edtDataprofissional = new javax.swing.JFormattedTextField();
        edtUF = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        edtCivilprofissional = new javax.swing.JComboBox();
        edtCNESprofissional = new javax.swing.JFormattedTextField();
        edtCBOprofissional = new javax.swing.JFormattedTextField();
        borda1 = new javax.swing.JLabel();
        borda2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel3 = new javax.swing.JPanel();
        Salvar = new javax.swing.JButton();
        Limpar = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel9.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel9.setText("Confirmar:");
        jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 360, -1, -1));

        jLabel7.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel7.setText("Nível de Acesso");
        jPanel2.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 300, -1, -1));

        nivelprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        nivelprofissional.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione o nível de acesso", "Assistente Social", "Atendente", "Enfermeiro", "Médico", "Psicologo" }));
        jPanel2.add(nivelprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 330, 230, -1));

        confirmarprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(confirmarprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 360, 150, -1));

        senhaprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(senhaprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 320, 150, -1));

        jLabel8.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel8.setText("Senha.:");
        jPanel2.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 320, -1, -1));

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel6.setText("Login.:");
        jPanel2.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 280, -1, -1));

        loginprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(loginprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 280, 210, -1));

        nome1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        nome1.setText("Nome.:");
        jPanel2.add(nome1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, -1, -1));

        edtNomeprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtNomeprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 40, 270, -1));

        RG1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        RG1.setText("RG.:");
        jPanel2.add(RG1, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 40, -1, -1));

        try {
            edtRGprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###########")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtRGprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtRGprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 40, 140, -1));

        CPF1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        CPF1.setText("CPF.:");
        jPanel2.add(CPF1, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 40, -1, -1));

        try {
            edtCPFprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtCPFprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        edtCPFprofissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtCPFprofissionalActionPerformed(evt);
            }
        });
        edtCPFprofissional.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                edtCPFprofissionalFocusLost(evt);
            }
        });
        jPanel2.add(edtCPFprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 40, 220, -1));

        enderço1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        enderço1.setText("Endereço:");
        enderço1.setToolTipText("");
        jPanel2.add(enderço1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 80, -1, -1));

        edtEnderecoprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtEnderecoprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 80, 270, -1));

        N1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        N1.setText("Nº.:");
        jPanel2.add(N1, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 80, 30, 20));

        edtNumprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtNumprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 80, 80, -1));

        bairro1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        bairro1.setText("Bairro.:");
        jPanel2.add(bairro1, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 80, -1, -1));

        edtBairroprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtBairroprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 80, 260, -1));

        telefone1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        telefone1.setText("Telefone.:");
        jPanel2.add(telefone1, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 160, -1, -1));

        try {
            edtTelefoneprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtTelefoneprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        edtTelefoneprofissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtTelefoneprofissionalActionPerformed(evt);
            }
        });
        jPanel2.add(edtTelefoneprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 160, 170, -1));

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel2.setText("CNES.:");
        jPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 120, -1, -1));

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel3.setText("CBO.:");
        jPanel2.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 120, -1, -1));

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel4.setText("Estado Civil.:");
        jPanel2.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 160, -1, -1));

        try {
            edtDataprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtDataprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        edtDataprofissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtDataprofissionalActionPerformed(evt);
            }
        });
        edtDataprofissional.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                edtDataprofissionalFocusLost(evt);
            }
        });
        jPanel2.add(edtDataprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 120, 160, -1));

        edtUF.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        edtUF.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Estado", "CE", "PE", "BH", "MA", " " }));
        jPanel2.add(edtUF, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 120, -1, -1));

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jLabel5.setText("Data Nasc:");
        jPanel2.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 120, -1, -1));

        edtCivilprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        edtCivilprofissional.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Solteiro", "Casado", "Divorciado", "Viuvo" }));
        edtCivilprofissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtCivilprofissionalActionPerformed(evt);
            }
        });
        jPanel2.add(edtCivilprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 160, 120, -1));

        try {
            edtCNESprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#######")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtCNESprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtCNESprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 120, 170, -1));

        try {
            edtCBOprofissional.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("######")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        edtCBOprofissional.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPanel2.add(edtCBOprofissional, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 120, 170, -1));

        borda1.setBackground(new java.awt.Color(51, 51, 51));
        borda1.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        borda1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Acesso", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 14), new java.awt.Color(51, 51, 51))); // NOI18N
        borda1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel2.add(borda1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, 860, 190));

        borda2.setBackground(new java.awt.Color(51, 51, 51));
        borda2.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        borda2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Cadastrar Profissional", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 14), new java.awt.Color(51, 51, 51))); // NOI18N
        borda2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel2.add(borda2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 860, 190));

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel2.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 270, 30, 150));

        jPanel3.setBackground(java.awt.SystemColor.activeCaption);
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        Salvar.setBackground(new java.awt.Color(255, 255, 255));
        Salvar.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        Salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/salvar.png"))); // NOI18N
        Salvar.setText("Salvar");
        Salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SalvarActionPerformed(evt);
            }
        });
        jPanel3.add(Salvar, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 10, -1, -1));

        Limpar.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        Limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/limpar.png"))); // NOI18N
        Limpar.setText("Limpar");
        Limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LimparActionPerformed(evt);
            }
        });
        jPanel3.add(Limpar, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 10, -1, -1));

        cancelar.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancelar.png"))); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarActionPerformed(evt);
            }
        });
        jPanel3.add(cancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 10, -1, -1));

        jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 450, 880, 50));

        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 880, 510));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/fundo2.jpg"))); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void edtTelefoneprofissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtTelefoneprofissionalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_edtTelefoneprofissionalActionPerformed

    private void SalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalvarActionPerformed
        // TODO add your handling code here:
        if(!edtNomeprofissional.getText().equals("")&&(!edtBairroprofissional.getText().equals(""))){
            
        
        
        Profissional profissional = new Profissional();
        
        
        profissional.setNomeprofissional(edtNomeprofissional.getText());
        profissional.setRGprofissional(edtRGprofissional.getText());
        profissional.setCPFprofissional(edtCPFprofissional.getText());
        profissional.setEnderecoprofissional(edtEnderecoprofissional.getText());
        profissional.setNumprofissional(Integer.parseInt(edtNumprofissional.getText()));
        profissional.setBairroprofissional(edtBairroprofissional.getText());
        profissional.setDataNascprofissional(edtDataprofissional.getText());
        profissional.setCBOprofissional(edtCBOprofissional.getText());
        profissional.setCNESprofissional(edtCNESprofissional.getText());
        profissional.setEstadocivilprofissional(edtCivilprofissional.getSelectedItem().toString());
        profissional.setTelefoneprofissional(edtTelefoneprofissional.getText());
        profissional.setEstadoprofissional(edtUF.getSelectedItem().toString());

        //SALVAR PROFISSIONAL
      profissionalDAO proDao = new profissionalDAO();
      proDao.salvar(profissional);
         

        //LOGIN DO PROFISSIONAL
        Login login = new Login();
        login.setLogin(loginprofissional.getText());
        login.setSenha(senhaprofissional.getText());
        login.setConfirmarSenha(confirmarprofissional.getText());
        login.setNivel(nivelprofissional.getSelectedItem().toString());
        login.setProfissional(profissional);
        
      //SALVAR LOGIN
      LoginDAO logDAO = new LoginDAO();
      logDAO.salvar(login);
        
      
       
      JOptionPane.showMessageDialog(edtNomeprofissional, 
                "Novo Profissional: "+profissional.getNomeprofissional()+
                ", Cadastrado com Sucesso!");
        }else{
            JOptionPane.showMessageDialog(rootPane,"Campos Obrigatorios");
                   
        }
         edtNomeprofissional.setText("");
        edtRGprofissional.setText("");
        edtCPFprofissional.setText("");
        edtEnderecoprofissional.setText("");
        edtNumprofissional.setText("");
        edtBairroprofissional.setText("");
        edtDataprofissional.setText("");
        edtCBOprofissional.setText("");
        edtCNESprofissional.setText("");
        edtCivilprofissional.setSelectedIndex(0);
        edtTelefoneprofissional.setText("");
        edtUF.setSelectedIndex(0);
        loginprofissional.setText("");
        senhaprofissional.setText("");
        confirmarprofissional.setText("");
        nivelprofissional.setSelectedIndex(0);
    }//GEN-LAST:event_SalvarActionPerformed

    private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_cancelarActionPerformed

    private void edtCPFprofissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtCPFprofissionalActionPerformed
        // TODO add your handling code here:
        
     



    }//GEN-LAST:event_edtCPFprofissionalActionPerformed

    private void LimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LimparActionPerformed
        
        edtNomeprofissional.setText("");
        edtRGprofissional.setText("");
        edtCPFprofissional.setText("");
        edtEnderecoprofissional.setText("");
        edtNumprofissional.setText("");
        edtBairroprofissional.setText("");
        edtDataprofissional.setText("");
        edtCBOprofissional.setText("");
        edtCNESprofissional.setText("");
        edtCivilprofissional.setSelectedIndex(0);
        edtTelefoneprofissional.setText("");
        edtUF.setSelectedIndex(0);
        
        
    }//GEN-LAST:event_LimparActionPerformed

    private void edtCivilprofissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtCivilprofissionalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_edtCivilprofissionalActionPerformed

    private void edtCPFprofissionalFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_edtCPFprofissionalFocusLost
        // TODO add your handling code here:
        if (!util.CPF(edtCPFprofissional.getText().toString().replaceAll("\\D*", ""))) {
            JOptionPane.showMessageDialog(rootPane, "Este CPF não é válido, Redigite!", "ERRO", JOptionPane.ERROR_MESSAGE);
            edtCPFprofissional.setText("");
            
            if (!edtCPFprofissional.isFocusOwner()) {
                
                edtCPFprofissional.requestFocus();
            }
        }
    }//GEN-LAST:event_edtCPFprofissionalFocusLost

    private void edtDataprofissionalFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_edtDataprofissionalFocusLost
        // TODO add your handling code here:
        if (!util.dataValida(edtDataprofissional.getText().toString())) {
            JOptionPane.showMessageDialog(rootPane, "Data inválida!", "ERRO", JOptionPane.ERROR_MESSAGE);
            edtDataprofissional.setText("");
            
            if (!edtDataprofissional.isFocusOwner()) {
                
                edtDataprofissional.requestFocus();
            }
        }
    }//GEN-LAST:event_edtDataprofissionalFocusLost

    private void edtDataprofissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtDataprofissionalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_edtDataprofissionalActionPerformed
       
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadProfissional.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadProfissional.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadProfissional.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadProfissional.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CadProfissional().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CPF1;
    private javax.swing.JButton Limpar;
    private javax.swing.JLabel N1;
    private javax.swing.JLabel RG1;
    private javax.swing.JButton Salvar;
    private javax.swing.JLabel bairro1;
    private javax.swing.JLabel borda1;
    private javax.swing.JLabel borda2;
    private javax.swing.JButton cancelar;
    private javax.swing.JPasswordField confirmarprofissional;
    private javax.swing.JTextField edtBairroprofissional;
    private javax.swing.JFormattedTextField edtCBOprofissional;
    private javax.swing.JFormattedTextField edtCNESprofissional;
    private javax.swing.JFormattedTextField edtCPFprofissional;
    private javax.swing.JComboBox edtCivilprofissional;
    private javax.swing.JFormattedTextField edtDataprofissional;
    private javax.swing.JTextField edtEnderecoprofissional;
    private javax.swing.JTextField edtNomeprofissional;
    private javax.swing.JTextField edtNumprofissional;
    private javax.swing.JFormattedTextField edtRGprofissional;
    private javax.swing.JFormattedTextField edtTelefoneprofissional;
    private javax.swing.JComboBox edtUF;
    private javax.swing.JLabel enderço1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField loginprofissional;
    private javax.swing.JComboBox nivelprofissional;
    private javax.swing.JLabel nome1;
    private javax.swing.JPasswordField senhaprofissional;
    private javax.swing.JLabel telefone1;
    // End of variables declaration//GEN-END:variables
}
